<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox-content">
        <form class="form-horizontal" method="post" action="#" id="attachment">
            <input type="hidden" name="customer_id" value="#{$customer_id}#">
            <div class="form-group">
                <label class="col-sm-2 control-label">附件名称</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text" placeholder="请输姓名" required id="name"/>
                    <span class="help-block m-b-none"></span></div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">选择文件</label>
                <div class="col-sm-8">
                    <input name="file" class="form-control" type="file" placeholder="选择上传文件" required id="file"/>
                    <span class="help-block m-b-none"></span></div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">附件介绍</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text" placeholder="附件介绍"  id="remark"/>
                    <span class="help-block m-b-none"></span></div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                    <button class="btn btn-w-m btn-info save-form" type="button">保存数据</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 自定义js -->
<script src="#{$smarty.const.APP}#/View/template/js/content.js?v=1.0.0"></script>
<script src="#{$smarty.const.APP}#/View/template/js/jquery.form.js?v=1.0.0"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $('.chosen-select').chosen({search_contains: true});
        $(".chosen-select").val("#{$customer_id}#").trigger("chosen:updated");

        $("body").on("click", ".save-form", function () {
            //FormData = $("form").serialize();

            var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
            if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
                alert("请选择图片");
                return;
            }


            $('#attachment').ajaxSubmit({
                type: "POST",
                url: "#{$smarty.const.ACT}#/crm/CstAttachment/cst_attachment_add/",
                success: function (data) {
                    if (data.rtnstatus == 'success') {
                        layer.msg('操作成功', {icon: 1});
                    }
                },
                complete: function () {
                    setTimeout(function () {
                        //关闭窗口
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    }, 800);

                },
            });
        });
    });
</script>
</body>
</html>